home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / TextServices.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  12.5 KB  |  368 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        TextServices.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT TextServices;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __TEXTSERVICES__}
  27. {$SETC __TEXTSERVICES__ := 1}
  28.  
  29. {$I+}
  30. {$SETC TextServicesIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __EVENTS__}
  40. {$I Events.p}
  41. {$ENDC}
  42. {    Quickdraw.p                                                    }
  43. {        MixedMode.p                                                }
  44. {        QuickdrawText.p                                            }
  45. {    OSUtils.p                                                    }
  46. {        Memory.p                                                }
  47.  
  48. {$IFC UNDEFINED __MENUS__}
  49. {$I Menus.p}
  50. {$ENDC}
  51.  
  52. {$IFC UNDEFINED __APPLEEVENTS__}
  53. {$I AppleEvents.p}
  54. {$ENDC}
  55. {    Errors.p                                                    }
  56. {    EPPC.p                                                        }
  57. {        PPCToolbox.p                                            }
  58. {            AppleTalk.p                                            }
  59. {        Processes.p                                                }
  60. {            Files.p                                                }
  61. {    Notification.p                                                }
  62.  
  63. {$IFC UNDEFINED __COMPONENTS__}
  64. {$I Components.p}
  65. {$ENDC}
  66.  
  67. {$PUSH}
  68. {$ALIGN MAC68K}
  69. {$LibExport+}
  70.  
  71. CONST
  72.     kTSMVersion                    = $200;                            { Version of the Text Services Manager is 2.0  }
  73.     kTextService                = 'tsvc';                        { component type for the component description }
  74.     kInputMethodService            = 'inpm';                        { component subtype for the component description }
  75. { Component Flags in ComponentDescription }
  76.     bTakeActiveEvent            = 15;                            { bit set if the component takes active event }
  77.     bHandleAERecording            = 16;                            { bit set if the component takes care of recording Apple Events <new in vers2.0> }
  78.     bScriptMask                    = $00007F00;                    { bit 8 - 14 }
  79.     bLanguageMask                = $000000FF;                    { bit 0 - 7  }
  80.     bScriptLanguageMask            = bScriptMask + bLanguageMask;    { bit 0 - 14  }
  81.  
  82. { Hilite styles }
  83.     kCaretPosition                = 1;                            { specify caret position }
  84.     kRawText                    = 2;                            { specify range of raw text }
  85.     kSelectedRawText            = 3;                            { specify range of selected raw text }
  86.     kConvertedText                = 4;                            { specify range of converted text }
  87.     kSelectedConvertedText        = 5;                            { specify range of selected converted text }
  88.  
  89. { Apple Event constants }
  90. { Event class }
  91.     kTextServiceClass            = kTextService;
  92. { event ID }
  93.     kUpdateActiveInputArea        = 'updt';                        { update the active Inline area }
  94.     kPos2Offset                    = 'p2st';                        { converting global coordinates to char position }
  95.     kOffset2Pos                    = 'st2p';                        { converting char position to global coordinates }
  96.     kShowHideInputWindow        = 'shiw';                        { show or hide the input window }
  97. { Event keywords }
  98.     keyAETSMDocumentRefcon        = 'refc';                        { TSM document refcon, typeLongInteger }
  99. { Note: keyAETSMScriptTag, keyAERequestedType, keyAETSMTextFont, keyAETextPointSize
  100.     typeAEText, typeIntlWritingCode, typeQDPoint, and keyAEAngle have been moved to 
  101.     AERegistry.h }
  102.     keyAEServerInstance            = 'srvi';                        { component instance }
  103.     keyAETheData                = 'kdat';                        { typeText }
  104.     keyAEFixLength                = 'fixl';                        { fix len ?? }
  105.     keyAEHiliteRange            = 'hrng';                        { hilite range array }
  106.     keyAEUpdateRange            = 'udng';                        { update range array }
  107.     keyAEClauseOffsets            = 'clau';                        { Clause Offsets array }
  108.     keyAECurrentPoint            = 'cpos';                        { current point }
  109.     keyAEDragging                = 'bool';                        { dragging falg }
  110.     keyAEOffset                    = 'ofst';                        { offset }
  111.     keyAERegionClass            = 'rgnc';                        { region class }
  112.     keyAEPoint                    = 'gpos';                        { current point }
  113.     keyAEBufferSize                = 'buff';                        { buffer size to get the text }
  114.     keyAEMoveView                = 'mvvw';                        { move view flag }
  115.     keyAELength                    = 'leng';                        { length }
  116.     keyAENextBody                = 'nxbd';                        { next or previous body }
  117. { optional keywords for Offset2Pos (Info about the active input area) }
  118.     keyAETextLineHeight            = 'ktlh';                        { typeShortInteger }
  119.     keyAETextLineAscent            = 'ktas';                        { typeShortInteger }
  120. { optional keywords for Pos2Offset }
  121.     keyAELeftSide                = 'klef';                        { type Boolean }
  122. { optional keywords for kShowHideInputWindow }
  123.     keyAEShowHideInputWindow    = 'shiw';                        { type Boolean }
  124. { for PinRange  }
  125.     keyAEPinRange                = 'pnrg';
  126. { Desc type ... }
  127.     typeComponentInstance        = 'cmpi';                        { server instance }
  128.     typeTextRangeArray            = 'tray';                        { text range array }
  129.     typeOffsetArray                = 'ofay';                        { offset array }
  130.     typeText                    = 'TEXT';                        { Plain text }
  131.     typeTextRange                = 'txrn';
  132.  
  133. { Desc type constants }
  134.     kTSMOutsideOfBody            = 1;
  135.     kTSMInsideOfBody            = 2;
  136.     kTSMInsideOfActiveInputArea    = 3;
  137.  
  138.     kNextBody                    = 1;
  139.     kPreviousBody                = 2;
  140.  
  141. { typeTextRange         'txrn' }
  142.  
  143. TYPE
  144.     TextRange = RECORD
  145.         fStart:                    LONGINT;
  146.         fEnd:                    LONGINT;
  147.         fHiliteStyle:            INTEGER;
  148.     END;
  149.     TextRangePtr = ^TextRange;
  150.  
  151.     TextRangeHandle = ^TextRangePtr;
  152.  
  153. { typeTextRangeArray    'txra' }
  154.     TextRangeArray = RECORD
  155.         fNumOfRanges:            INTEGER;                                { specify the size of the fRange array }
  156.         fRange:                    ARRAY [0..0] OF TextRange;                { when fNumOfRanges > 1, the size of this array has to be calculated }
  157.     END;
  158.     TextRangeArrayPtr = ^TextRangeArray;
  159.  
  160.     TextRangeArrayHandle = ^TextRangeArrayPtr;
  161.  
  162. { typeOffsetArray        'offa' }
  163.     OffsetArray = RECORD
  164.         fNumOfOffsets:            INTEGER;                                { specify the size of the fOffset array }
  165.         fOffset:                ARRAY [0..0] OF LONGINT;                { when fNumOfOffsets > 1, the size of this array has to be calculated }
  166.     END;
  167.     OffsetArrayPtr = ^OffsetArray;
  168.  
  169.     OffsetArrayHandle = ^OffsetArrayPtr;
  170.  
  171.     TSMDocumentID = Ptr;
  172.  
  173.     InterfaceTypeList = ARRAY [0..0] OF OSType;
  174.  
  175. { Text Service Info List }
  176.     TextServiceInfo = RECORD
  177.         fComponent:                Component;
  178.         fItemName:                Str255;
  179.     END;
  180.     TextServiceInfoPtr = ^TextServiceInfo;
  181.  
  182.     TextServiceList = RECORD
  183.         fTextServiceCount:        INTEGER;                                { number of entries in the 'fServices' array }
  184.         fServices:                ARRAY [0..0] OF TextServiceInfo;        { Note: array of 'TextServiceInfo' records follows }
  185.     END;
  186.     TextServiceListPtr = ^TextServiceList;
  187.  
  188.     TextServiceListHandle = ^TextServiceListPtr;
  189.  
  190.     ScriptLanguageRecord = RECORD
  191.         fScript:                ScriptCode;
  192.         fLanguage:                LangCode;
  193.     END;
  194.     ScriptLanguageSupport = RECORD
  195.         fScriptLanguageCount:    INTEGER;                                { number of entries in the 'fScriptLanguageArray' array }
  196.         fScriptLanguageArray:    ARRAY [0..0] OF ScriptLanguageRecord;    { Note: array of 'ScriptLanguageRecord' records follows }
  197.     END;
  198.     ScriptLanguageSupportPtr = ^ScriptLanguageSupport;
  199.  
  200.     ScriptLanguageSupportHandle = ^ScriptLanguageSupportPtr;
  201.  
  202.  
  203. CONST
  204. { Low level routines which are dispatched directly to the Component Manager }
  205.     kCMGetScriptLangSupport        = $0001;                        { Component Manager call selector 1 }
  206.     kCMInitiateTextService        = $0002;                        { Component Manager call selector 2 }
  207.     kCMTerminateTextService        = $0003;                        { Component Manager call selector 3 }
  208.     kCMActivateTextService        = $0004;                        { Component Manager call selector 4 }
  209.     kCMDeactivateTextService    = $0005;                        { Component Manager call selector 5 }
  210.     kCMTextServiceEvent            = $0006;                        { Component Manager call selector 6 }
  211.     kCMGetTextServiceMenu        = $0007;                        { Component Manager call selector 7 }
  212.     kCMTextServiceMenuSelect    = $0008;                        { Component Manager call selector 8 }
  213.     kCMFixTextService            = $0009;                        { Component Manager call selector 9 }
  214.     kCMSetTextServiceCursor        = $000A;                        { Component Manager call selector 10 }
  215.     kCMHidePaletteWindows        = $000B;                        { Component Manager call selector 11 }
  216.  
  217. { High level TSM routines }
  218.  
  219. FUNCTION NewTSMDocument(numOfInterface: INTEGER; VAR supportedInterfaceTypes: InterfaceTypeList; VAR idocID: TSMDocumentID; refcon: LONGINT): OSErr;
  220.     {$IFC NOT GENERATINGCFM}
  221.     INLINE $7000, $AA54;
  222.     {$ENDC}
  223. FUNCTION DeleteTSMDocument(idocID: TSMDocumentID): OSErr;
  224.     {$IFC NOT GENERATINGCFM}
  225.     INLINE $7001, $AA54;
  226.     {$ENDC}
  227. FUNCTION ActivateTSMDocument(idocID: TSMDocumentID): OSErr;
  228.     {$IFC NOT GENERATINGCFM}
  229.     INLINE $7002, $AA54;
  230.     {$ENDC}
  231. FUNCTION DeactivateTSMDocument(idocID: TSMDocumentID): OSErr;
  232.     {$IFC NOT GENERATINGCFM}
  233.     INLINE $7003, $AA54;
  234.     {$ENDC}
  235. FUNCTION TSMEvent(VAR event: EventRecord): BOOLEAN;
  236.     {$IFC NOT GENERATINGCFM}
  237.     INLINE $7004, $AA54;
  238.     {$ENDC}
  239. FUNCTION TSMMenuSelect(menuResult: LONGINT): BOOLEAN;
  240.     {$IFC NOT GENERATINGCFM}
  241.     INLINE $7005, $AA54;
  242.     {$ENDC}
  243. FUNCTION SetTSMCursor(mousePos: Point): BOOLEAN;
  244.     {$IFC NOT GENERATINGCFM}
  245.     INLINE $7006, $AA54;
  246.     {$ENDC}
  247. FUNCTION FixTSMDocument(idocID: TSMDocumentID): OSErr;
  248.     {$IFC NOT GENERATINGCFM}
  249.     INLINE $7007, $AA54;
  250.     {$ENDC}
  251. FUNCTION GetServiceList(numOfInterface: INTEGER; VAR supportedInterfaceTypes: OSType; VAR serviceInfo: TextServiceListHandle; VAR seedValue: LONGINT): OSErr;
  252.     {$IFC NOT GENERATINGCFM}
  253.     INLINE $7008, $AA54;
  254.     {$ENDC}
  255. FUNCTION OpenTextService(idocID: TSMDocumentID; aComponent: Component; VAR aComponentInstance: ComponentInstance): OSErr;
  256.     {$IFC NOT GENERATINGCFM}
  257.     INLINE $7009, $AA54;
  258.     {$ENDC}
  259. FUNCTION CloseTextService(idocID: TSMDocumentID; aComponentInstance: ComponentInstance): OSErr;
  260.     {$IFC NOT GENERATINGCFM}
  261.     INLINE $700A, $AA54;
  262.     {$ENDC}
  263. FUNCTION SendAEFromTSMComponent({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP): OSErr;
  264.     {$IFC NOT GENERATINGCFM}
  265.     INLINE $700B, $AA54;
  266.     {$ENDC}
  267. FUNCTION InitTSMAwareApplication: OSErr;
  268.     {$IFC NOT GENERATINGCFM}
  269.     INLINE $7014, $AA54;
  270.     {$ENDC}
  271. FUNCTION CloseTSMAwareApplication: OSErr;
  272.     {$IFC NOT GENERATINGCFM}
  273.     INLINE $7015, $AA54;
  274.     {$ENDC}
  275. { Utilities }
  276. FUNCTION SetDefaultInputMethod(ts: Component; VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  277.     {$IFC NOT GENERATINGCFM}
  278.     INLINE $700C, $AA54;
  279.     {$ENDC}
  280. FUNCTION GetDefaultInputMethod(VAR ts: Component; VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  281.     {$IFC NOT GENERATINGCFM}
  282.     INLINE $700D, $AA54;
  283.     {$ENDC}
  284. FUNCTION SetTextServiceLanguage(VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  285.     {$IFC NOT GENERATINGCFM}
  286.     INLINE $700E, $AA54;
  287.     {$ENDC}
  288. FUNCTION GetTextServiceLanguage(VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  289.     {$IFC NOT GENERATINGCFM}
  290.     INLINE $700F, $AA54;
  291.     {$ENDC}
  292. FUNCTION UseInputWindow(idocID: TSMDocumentID; useWindow: BOOLEAN): OSErr;
  293.     {$IFC NOT GENERATINGCFM}
  294.     INLINE $7010, $AA54;
  295.     {$ENDC}
  296. FUNCTION NewServiceWindow(wStorage: UNIV Ptr; {CONST}VAR boundsRect: Rect; title: ConstStr255Param; visible: BOOLEAN; theProc: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; ts: ComponentInstance; VAR window: WindowPtr): OSErr;
  297.     {$IFC NOT GENERATINGCFM}
  298.     INLINE $7011, $AA54;
  299.     {$ENDC}
  300. FUNCTION CloseServiceWindow(window: WindowPtr): OSErr;
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $7012, $AA54;
  303.     {$ENDC}
  304. FUNCTION GetFrontServiceWindow(VAR window: WindowPtr): OSErr;
  305.     {$IFC NOT GENERATINGCFM}
  306.     INLINE $7013, $AA54;
  307.     {$ENDC}
  308. FUNCTION FindServiceWindow(thePoint: Point; VAR theWindow: WindowPtr): INTEGER;
  309.     {$IFC NOT GENERATINGCFM}
  310.     INLINE $7017, $AA54;
  311.     {$ENDC}
  312. { Low level TSM routines }
  313. FUNCTION GetScriptLanguageSupport(ts: ComponentInstance; VAR scriptHdl: ScriptLanguageSupportHandle): ComponentResult;
  314.     {$IFC NOT GENERATINGCFM}
  315.     INLINE $2F3C, $04, $0001, $7000, $A82A;
  316.     {$ENDC}
  317. FUNCTION InitiateTextService(ts: ComponentInstance): ComponentResult;
  318.     {$IFC NOT GENERATINGCFM}
  319.     INLINE $2F3C, $00, $0002, $7000, $A82A;
  320.     {$ENDC}
  321. FUNCTION TerminateTextService(ts: ComponentInstance): ComponentResult;
  322.     {$IFC NOT GENERATINGCFM}
  323.     INLINE $2F3C, $00, $0003, $7000, $A82A;
  324.     {$ENDC}
  325. FUNCTION ActivateTextService(ts: ComponentInstance): ComponentResult;
  326.     {$IFC NOT GENERATINGCFM}
  327.     INLINE $2F3C, $00, $0004, $7000, $A82A;
  328.     {$ENDC}
  329. FUNCTION DeactivateTextService(ts: ComponentInstance): ComponentResult;
  330.     {$IFC NOT GENERATINGCFM}
  331.     INLINE $2F3C, $00, $0005, $7000, $A82A;
  332.     {$ENDC}
  333. FUNCTION TextServiceEvent(ts: ComponentInstance; numOfEvents: INTEGER; VAR event: EventRecord): ComponentResult;
  334.     {$IFC NOT GENERATINGCFM}
  335.     INLINE $2F3C, $06, $0006, $7000, $A82A;
  336.     {$ENDC}
  337. FUNCTION GetTextServiceMenu(ts: ComponentInstance; VAR serviceMenu: MenuHandle): ComponentResult;
  338.     {$IFC NOT GENERATINGCFM}
  339.     INLINE $2F3C, $4, $0007, $7000, $A82A;
  340.     {$ENDC}
  341. FUNCTION TextServiceMenuSelect(ts: ComponentInstance; serviceMenu: MenuHandle; item: INTEGER): ComponentResult;
  342.     {$IFC NOT GENERATINGCFM}
  343.     INLINE $2F3C, $06, $0008, $7000, $A82A;
  344.     {$ENDC}
  345. FUNCTION FixTextService(ts: ComponentInstance): ComponentResult;
  346.     {$IFC NOT GENERATINGCFM}
  347.     INLINE $2F3C, $00, $0009, $7000, $A82A;
  348.     {$ENDC}
  349. FUNCTION SetTextServiceCursor(ts: ComponentInstance; mousePos: Point): ComponentResult;
  350.     {$IFC NOT GENERATINGCFM}
  351.     INLINE $2F3C, $04, $000A, $7000, $A82A;
  352.     {$ENDC}
  353. FUNCTION HidePaletteWindows(ts: ComponentInstance): ComponentResult;
  354.     {$IFC NOT GENERATINGCFM}
  355.     INLINE $2F3C, $00, $000B, $7000, $A82A;
  356.     {$ENDC}
  357.  
  358. {$ALIGN RESET}
  359. {$POP}
  360.  
  361. {$SETC UsingIncludes := TextServicesIncludes}
  362.  
  363. {$ENDC} {__TEXTSERVICES__}
  364.  
  365. {$IFC NOT UsingIncludes}
  366.  END.
  367. {$ENDC}
  368.